package com.blog.video.service.impl;

import com.blog.video.dao.ArticleDao;
import com.blog.video.pojo.Article;
import com.blog.video.service.ArticleService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import com.blog.video.util.IdWorker;

import java.util.List;

/**
 * 这里分页使用的是pagehelper
 */
@Service
@Transactional(readOnly = false)
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private IdWorker idWorker;

    @Autowired
    private ArticleDao articleDao;

    public List<Article> findAll(int page, int size) {
        return articleDao.selectList(null);
    }

    public Article findById(String id) {
        Article article = articleDao.selectById(id);
        return article;
    }

    public void insert(Article article) {
        articleDao.insert(article);
    }

    public void update(Article article) {
        articleDao.updateById(article);
    }

    public void deleteById(String id) {
        articleDao.deleteById(id);
    }
}